$NG.AllReady(
    //表头页面逻辑
    function (page, { useAction, useDataIndexChange, useBeforeClick,useUpdateRow, useUpdateRows }) {
        const mstform = $NG.getCmpApi("p_form_pc_stakeholders_m");
        const dgrid = $NG.getCmpApi("p_form_pc_stakeholders_d");
        console.log("page is ready");

        $NG.updateUI((updater)=>{
            updater.form.p_form_pc_stakeholders_m.u_phidkey.setProps({
                hidden:true
            })
        })

        if (page.oType == "add") {
            $NG.updateState((updater)=>{
                updater.data.p_form_pc_stakeholders_m.setProps({
                    u_phidkey:new Date().getTime()
                })
            })
            mstform.setReadOnly("u_sjbh");
            mstform.setReadOnly("u_opportunity");
        }
        if (page.oType == "edit") {
            mstform.setReadOnly("phid_pc");

        }


    // useBeforeClick(async (prop) => {
	// 	const phidkey = mstform.getItem("u_phidkey").getValue();
	// 	const resBody = await $NG.request.get({
    //         url: "http://nginx.clouddev.hisense.com/sd/sdToCrm/apply/stakeholders/"+phidkey,
    //         header: {
    //             "Content-Type": "application/json",
    //         },
    //     });
    //     console.log(`后台接口接收信息`,resBody);
    //     return false
	// }, "save");

        if (dgrid) {
            // 实现对表体单元格设置必输和只读
            dgrid.subscribe(({ dataIndex, row }) => {
                xb = "null";
                if (dataIndex == "u_source") {
                    xb = dataIndex;
                }
                console.log(dgrid.getChange());
            }, "startEditing");

            dgrid.subscribe(({ dataIndex, row }) => {
                console.log(dataIndex, row);
                var u_source = "SD";
                u_source = dgrid.getRows()[dgrid.getCheckedIndexes()[0]].u_source;
                if (u_source != "SD") {
                    dgrid.endEditing();
                    $NG.alert("只有干系人来源为SD的项目干系人才能进行编辑");
                }
            }, "onCheckedChange");
        }
        useUpdateRows(({ args }) => {
            const _arr = dgrid.getRows()
            _arr.forEach(element => {
                if (element.u_source == "" || element.u_source == undefined) {
                    element.u_source = "SD"
                }
            });
            dgrid.refreshView()
        }, "p_form_pc_stakeholders_d")
    },
    //编辑页面逻辑
    //  function (editPage, { useAction }) {
    //   console.log("editPage is ready");
    //   const listToolbar = $NG.getCmpApi("toolbar");
    //    listToolbar.getItem("add").setHidden();
    //   },
    //列表页面逻辑
    function (listPage, { useAction }) {
        console.log("listPage is ready");
    }
);
